package java_class_work.week08.internet.castUpper;

import java.io.*;
import java.net.Socket;

/**
 * @Author Tiam
 * @Date 2022/11/1 11:09
 * @Description:
 */
public class Client {
    public static void main(String[] args) {
        try {
            Socket socket = new Socket("127.0.0.1", 8888);

            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

            PrintWriter out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()),true);
            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

            String line = null;
            while ((line=bufferedReader.readLine())!=null){
                if("over".equalsIgnoreCase(line)) break;
                out.println(line);

                String res = in.readLine();
                System.out.println("服务端返回的结果:"+res);
            }
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
